/// Copyright (c) Microsoft Corporation.  All rights reserved.

using System;
using System.Collections;
using System.Text;
using System.ComponentModel;
using System.Windows.Forms;
using NUnit.Framework;
using NUnit.Extensions.Forms;
using Microsoft.VSPowerToys.PackInstaller;
using System.Threading;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Diagnostics;

namespace GUITestScenarios
{
    public class ErrorMessages
    {
        private Collection<string> errorMessages;
        public ErrorMessages()
        {
            errorMessages = new Collection<string>();
        }
        /// <summary>
        /// Private method to print all error messages from a test.
        /// Normally, tests would Assert when they found something wrong. 
        /// However, since the test logic is running in a delegate callback,
        /// that looks like an exception in the product and, even worse, requires 
        /// manual intervention in the test. So, we're just adding error messages to a 
        /// collection and, when we get back to the test DLL, asserting that there 
        /// were no errors. The test DLL uses this method to write the messages to 
        /// the console before asserting that there were no errors. 
        /// </summary>
        /// <param name="testName"></param>
        public void printErrors(string testName)
        {
            foreach (string s in errorMessages)
            {
                Console.WriteLine(testName + ": Error - " + s);
            }
            if (errorMessages.Count > 0)
                Console.WriteLine();
        }
        public void Add(string message)
        {
            this.errorMessages.Add(message);
        }
        public int Count { get { return this.errorMessages.Count; } }

    }
}
